package babo.cd.physicalexperiment.fragment;

import android.content.Intent;
import android.net.Uri;
import android.view.View;

import com.google.gson.Gson;

import java.text.SimpleDateFormat;
import java.util.Locale;

import babo.cd.physicalexperiment.activity.ShiyanListActivity;
import babo.cd.physicalexperiment.bean.ShiyanListBean;
import babo.cd.physicalexperiment.bean.YuyueListbean;
import babo.cd.physicalexperiment.databinding.FragmentHomepageBinding;
import babo.cd.physicalexperiment.utils.OKCallback;
import babo.cd.physicalexperiment.utils.OkUtils;
import babo.cd.physicalexperiment.utils.Out;
import babo.cd.physicalexperiment.utils.URLS;

public class HomePageFragment extends BaseFragment {
    FragmentHomepageBinding binding;
    YuyueListbean yuyueListbean;

    @Override
    public View getLayout() {
        binding = FragmentHomepageBinding.inflate(getLayoutInflater());
        return binding.getRoot();
    }

    @Override
    public void initView() {
    }

    @Override
    public void initData() {

    }

    @Override
    public void onResume() {
        super.onResume();

    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);

    }

    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);


    }



    private void getSHiyanList() {
        OkUtils.GetOk(URLS.getshiyanList, new OKCallback(getActivity()) {
            @Override
            public void Sucess(String str) {
                super.Sucess(str);

                Gson gson = new Gson();
                ShiyanListBean shiyanListBean = gson.fromJson(str, ShiyanListBean.class);


            }
        });
    }

    private void doYuyue(String s) {
        SimpleDateFormat sdfTwo = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());

        String time11 = sdfTwo.format(System.currentTimeMillis());

        Out.out("当前时间：" + Uri.encode(time11));


        OkUtils.GetOk(URLS.doyuyue + "?expId=" + s + "&appointmentTime=" + Uri.encode(time11), new OKCallback(getActivity()) {
            @Override
            public void Sucess(String str) {
                super.Sucess(str);
                Out.out("do预约信息：" + str);
            }

            @Override
            public void Eorror(int code) {
                super.Eorror(code);
                Out.out("do预约code=" + code);
            }
        });
    }

    @Override
    public void setListener() {
        binding.rlMkex.setOnClickListener(v -> {
            Intent intent = new Intent(getActivity(), ShiyanListActivity.class);
            intent.putExtra("type", 1);
            startActivity(intent);
        });
        binding.rlZiyouluoti.setOnClickListener(v -> {
            Intent intent = new Intent(getActivity(), ShiyanListActivity.class);
            intent.putExtra("type", 2);
            startActivity(intent);
        });
    }
}
